﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace INSTA.BankApplication.Engine
{
    /// <summary>
    /// Factory class that builds AccountBase-derived
    /// classes.
    /// </summary>
    public static class AccountFactory
    {
        // Constants that hold the min/max boundaries 
        // for each account type.
        public const int MIN_DEPOSIT_STANDARD   = 0;
        public const int MAX_DEPOSIT_STANDARD   = 500;
        public const int MIN_DEPOSIT_SILVER     = 500;
        public const int MAX_DEPOSIT_SILVER     = 5000;
        public const int MIN_DEPOSIT_GOLD       = 5000;


        /// <summary>
        /// Creates the correct Account type,
        /// depending on the initial deposit.
        /// </summary>
        /// <param name="c">The c.</param>
        /// <param name="initialDeposit">The initial deposit.</param>
        /// <returns>the correct account type.</returns>
        internal static AccountBase Create(IBankCustomer c, double initialDeposit)
        {
            AccountBase result = null;

            if (initialDeposit >= MIN_DEPOSIT_STANDARD && initialDeposit < MAX_DEPOSIT_STANDARD)
            {
                result = new StandardAccount(c, initialDeposit);
            }
            else if (initialDeposit >= MIN_DEPOSIT_SILVER && initialDeposit < MAX_DEPOSIT_SILVER)
            {
                result = new SilverAccount(c, initialDeposit);
            }
            else if (initialDeposit >= MIN_DEPOSIT_GOLD)
            {
                result = new GoldAccount(c, initialDeposit);
            }
            else
            {
                // Case where the initial deposit is negative.
                throw new ArgumentException("initial deposit must be positive");
            }
                  

            // Let's return the newly created account.
            return result;

        }










    }
}
